/**
 * @MockClient.java  COPYRIGHT xiaojian
 * 
 * Created on 2017年7月12日 下午4:43:17
 */
package xj.toolkit.access;

import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

import org.apache.commons.io.IOUtils;

import xiaojian.toolkit.util.ByteUtils;

/**
 * @author <a href="mailto:cxj2000@gmail.com">xiaojian.cao</a>
 *
 */
public class MockClient {
	
	//public static byte[] req = new byte[]{1, 0, 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 16, 0, 10, 0, 11, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
	public static byte[] req = new byte[]{1, 0, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 110, 0, 0, 0, 14, 0, 5, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 123, 125};

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {
		Socket socket = new Socket("127.0.0.1", 8092);
		
		OutputStream out = socket.getOutputStream();
		IOUtils.write(req, out);
		
		Thread.sleep(10 * 1000);
		
		InputStream in = socket.getInputStream();

		byte[] b = new byte[512];
		
		in.read(b);
		
		System.out.println(ByteUtils.bytesAsTLVHexString(b, 512));
		System.out.println(new String(b));
		
		IOUtils.closeQuietly(in);
		IOUtils.closeQuietly(out);
		
		socket.close();
	}

}
